package server.com.acme.bankapp.domain.bank;

import java.io.Serializable;

import server.com.acme.exceptions.NotEnoughFundsException;
import server.com.acme.exceptions.OverDraftLimitExceededException;

public abstract class AbstractAccount implements Serializable {

	private static final long serialVersionUID = 1L;
	protected int id;
	protected double balance;

	public AbstractAccount(final double amount) {
		this.balance = amount;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(final double amount) {
		this.balance = amount;
	}

	public abstract void deposit(final double amount);

	public abstract void withdraw(final double amount)
			throws OverDraftLimitExceededException, NotEnoughFundsException;

	public abstract double maximumAmountToWithdraw();

	@Override
	public int hashCode() {
		return id;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractAccount other = (AbstractAccount) obj;
		if (id != other.id)
			return false;
		return true;
	}

	public void decimalValue() {
		System.out.println(Math.round(balance));
	}

}
